﻿#include "Mocker.h"
#include <QString>
#include <QDir>
#include <QtTest>
#include <QCoreApplication>
#include "AoiReq.h"
#include "HWUtils.h"
#include "ImageCode.h"

using namespace aoi;
using namespace mock;

QString ImgMocker::mockerGetBase64FromSmtImg()
{
    QString folderPath = "E:/atlas/opt_worksapce/opt_test_pics/200dk_grey/12.jpg";
    SMTImage* img = new SMTImage();
    QDir dir;
    if (dir.exists(folderPath))
    {
        img->read(folderPath.toLocal8Bit().constData());
    }
    ReqFile reqFile;
    QByteArray res = SmtImagetoBase64(img);
    QString imgData(res);
    return imgData;
}

QString RspMocker::getMockAoiRsp_DetPlusDet()
{
    return R"(
{
  "det.jpg": [
    {
      "Label": "screw1",
      "Score": 1.0,
      "Box": {
        "X": 0,
        "Y": 0,
        "Width": 100,
        "Height": 100,
        "Angle": 0
      }
    },
    {
      "Label": "screw2",
      "Score": 1.0,
      "Box": {
        "X": 0,
        "Y": 0,
        "Width": 100,
        "Height": 100,
        "Angle": 0
      }
    },
    {
      "RegisterMatrix": [
        [
          1,
          0,
          0
        ],
        [
          0,
          1,
          0
        ],
        [
          0,
          0,
          1
        ],
        [
          0,
          0,
          0
        ]
      ]
    },
    {
      "IsSuccess": true,
      "InferenceTime": {
        "All": 0.6090652942657471,
        "PostAI": 0.014759063720703125,
        "Stream": 0.5791411399841309
      }
    }
  ]
}
        )";
}
QString RspMocker::getMockAoiRsp_DetPlusDetCls()
{
    return R"(
{
  "det_cls.jpg": [
    {
      "Label": "screw1",
      "Score": 1.0,
      "Box": {
        "X": 0,
        "Y": 0,
        "Width": 100,
        "Height": 100,
        "Angle": 0
      },
      "Classification": {
        "Label": "screw1_1",
        "Score": 1.0,
        "Box": {
          "X": 0,
          "Y": 0,
          "Width": 100,
          "Height": 100,
          "Angle": 0
        }
      }
    },
    {
      "Label": "screw1",
      "Score": 1.0,
      "Box": {
        "X": 0,
        "Y": 0,
        "Width": 100,
        "Height": 100,
        "Angle": 0
      },
      "Classification": {
        "Label": "screw2_1",
        "Score": 1.0,
        "Box": {
          "X": 0,
          "Y": 0,
          "Width": 100,
          "Height": 100,
          "Angle": 0
        }
      }
    },
    {
      "RegisterMatrix": [
        [
          1,
          0,
          0
        ],
        [
          0,
          1,
          0
        ],
        [
          0,
          0,
          1
        ],
        [
          0,
          0,
          0
        ]
      ]
    },
    {
      "IsSuccess": true,
      "InferenceTime": {
        "All": 0.6090652942657471,
        "PostAI": 0.014759063720703125,
        "Stream": 0.5791411399841309
      }
    }
  ]
}
        )";
}

QString RspMocker::getMockAoiRsp_DetPlusOcr()
{
    return R"(
{
  "ocr.jpg": [
    {
      "Label": "screw1",
      "Score": 1.0,
      "Box": {
        "X": 0,
        "Y": 0,
        "Width": 100,
        "Height": 100,
        "Angle": 0
      },
      "OCR": {
        "OCRText": "ACD",
        "Quad": {
          "TopLeft": {
            "X": 0,
            "Y": 0
          },
          "TopRight": {
            "X": 0,
            "Y": 0
          },
          "BottomLeft": {
            "X": 0,
            "Y": 0
          },
          "BottomRight": {
            "X": 0,
            "Y": 0
          }
        },
        "Score": 1.0
      }
    },
    {
      "Label": "screw2",
      "Score": 1.0,
      "Box": {
        "X": 0,
        "Y": 0,
        "Width": 100,
        "Height": 100,
        "Angle": 0
      },
      "OCR": {
        "OCRText": "LGS",
        "Quad": {
          "TopLeft": {
            "X": 0,
            "Y": 0
          },
          "TopRight": {
            "X": 0,
            "Y": 0
          },
          "BottomLeft": {
            "X": 0,
            "Y": 0
          },
          "BottomRight": {
            "X": 0,
            "Y": 0
          }
        },
        "Score": 1.0
      }
    },
    {
      "RegisterMatrix": [
        [
          1,
          0,
          0
        ],
        [
          0,
          1,
          0
        ],
        [
          0,
          0,
          1
        ],
        [
          0,
          0,
          0
        ]
      ]
    },
    {
      "IsSuccess": true,
      "InferenceTime": {
        "All": 0.6090652942657471,
        "PostAI": 0.014759063720703125,
        "Stream": 0.5791411399841309
      }
    }
  ]
}
        )";
}

QString RspMocker::getMockAoiRsp_DetPlusSeg()
{
    return R"(
{
  "seg.jpg": [
    {
      "Label": "screw1",
      "Score": 1.0,
      "Box": {
        "X": 0,
        "Y": 0,
        "Width": 100,
        "Height": 100,
        "Angle": 0
      },
      "Segmentation": {
        "CodeType": "JPG",
        "Mask": "iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAAAAADmVT4XAAABp0lEQVR4AcXBQXaDUAwEwW7uf2aURXD4dmyjhXhTJXeSU/GW3EgWxVtyG3lRvCF3kX+K/+Qe8l7xQm4hnxTP5AbyRfFE5slXxUrGyYViIePkSnGSaXKpOMk0uVb8kWHSUTzIMOkoHmSW9BQHmSU9xUFGSVNxkFHSVBxklDQVBxklTcVBRklX8UtGSVfxS0ZJV/FLRklTcZBR0lQcZJQ0FQcZJU3FQUZJU3GQWdJSPMgsaSkeZJg0FH9kmDQUf2SaXCpOMk0uFScZJxeKhcyTr4qV3EC+KJ7IHeSj4pncQj4oXsg95K3ildxGXhX/yX3kSfGO3E6KzyRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMujZOO2OkaWOxM0aaNlY7U6RpY7UzRZo2FjtjpGljsTNGmjZWO1OkaWO1M0WaNlY7U6RpY7EzRpo2FjtjpGvjtDPmB9k3N4FhwuiJAAAAAElFTkSuQmCC",
        "Score": 1.0,
        "LabelMap": {
          "1": "person",
          "2": "cat",
          "3": "dog"
        },
        "Box": {
          "X": 0,
          "Y": 0,
          "Width": 100,
          "Height": 100
        }
      }
    },
    {
      "Label": "screw2",
      "Score": 1.0,
      "Box": {
        "X": 0,
        "Y": 0,
        "Width": 100,
        "Height": 100,
        "Angle": 0
      },
      "Segmentation": {
        "CodeType": "JPG",
        "Mask": "iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAAAAADmVT4XAAABp0lEQVR4AcXBQXaDUAwEwW7uf2aURXD4dmyjhXhTJXeSU/GW3EgWxVtyG3lRvCF3kX+K/+Qe8l7xQm4hnxTP5AbyRfFE5slXxUrGyYViIePkSnGSaXKpOMk0uVb8kWHSUTzIMOkoHmSW9BQHmSU9xUFGSVNxkFHSVBxklDQVBxklTcVBRklX8UtGSVfxS0ZJV/FLRklTcZBR0lQcZJQ0FQcZJU3FQUZJU3GQWdJSPMgsaSkeZJg0FH9kmDQUf2SaXCpOMk0uFScZJxeKhcyTr4qV3EC+KJ7IHeSj4pncQj4oXsg95K3ildxGXhX/yX3kSfGO3E6KzyRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMwiRMujZOO2OkaWOxM0aaNlY7U6RpY7UzRZo2FjtjpGljsTNGmjZWO1OkaWO1M0WaNlY7U6RpY7EzRpo2FjtjpGvjtDPmB9k3N4FhwuiJAAAAAElFTkSuQmCC",
        "Score": 1.0,
        "LabelMap": {
          "1": "person",
          "2": "cat",
          "3": "dog"
        },
        "Box": {
          "X": 0,
          "Y": 0,
          "Width": 100,
          "Height": 100
        }
      }
    },
    {
      "RegisterMatrix": [
        [
          1,
          0,
          0
        ],
        [
          0,
          1,
          0
        ],
        [
          0,
          0,
          1
        ],
        [
          0,
          0,
          0
        ]
      ]
    },
    {
      "IsSuccess": true,
      "InferenceTime": {
        "All": 0.6090652942657471,
        "PostAI": 0.014759063720703125,
        "Stream": 0.5791411399841309
      }
    }
  ]
}
        )";
}